<?php

namespace App\Modules\Admin\Services\Water;

use App\Modules\Admin\Entities\Member\UserWaterCardModel;
use App\Modules\Admin\Entities\Member\WaterCardModel;
use App\Modules\Admin\Services\BaseService;

class WaterCardService extends BaseService
{

    public function __construct(WaterCardModel $model)
    {
        $this->model = $model;
    }
    public function lists(array $params) : array
    {

        $params['where_callback'] = function($query) use ($params){
            $request = request();
            // 按照名称进行搜索
            if (!empty($search = $request->input('search', ''))){
                $query->where('card_no', 'LIKE', '%' . trim($search) . '%');
            }
            if (!empty($search = $request->input('uid', ''))){
                $query->where('user_id', 'LIKE', '%' . trim($search) . '%');
            }
        };
        return parent::lists($params); // TODO: Change the autogenerated stub
    }
}
